package com.wx.servlet;

import com.wx.entry.SmbmsUser;
import com.wx.service.SmbmsUserService;
import com.wx.service.impl.SmbmsUserServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

public class QueryUserServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        //准备数据 从数据库当中查找数据，并放到session 当中去
        //servlet ==>service ==> dao
        SmbmsUserService smbmsUserService = new SmbmsUserServiceImpl();
        List<SmbmsUser>  smbmsUserList = smbmsUserService.getSmbmsUserAll();
        HttpSession session = req.getSession();
        session.setAttribute("userList",smbmsUserList);
        resp.sendRedirect("userlist.jsp");
    }
}
